<?php 
 include_once dirname(__FILE__)."/config.php";
 class unite1_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_ID;
		 protected $_NOM_UNITE;
		 protected $_CODE_UNITE;
		 protected $_NATURE;
		 protected $_CODE_ETABLISSEMENT;
		 protected $_CODE_UNIVERSITE;
		 protected $_CODE_DIPLOME;
		 protected $_SEMESTRE;
		 protected $_CODE_DOMAINE;
		 protected $_CODE_MENTION;
		 protected $_CODE_NIVEAU;
		 public function get_name_table(){ return "unite1";}
		 public function get_name_ID(){ return "ID";}
		 public function get_name_NOM_UNITE(){ return "NOM_UNITE";}
		 public function get_name_CODE_UNITE(){ return "CODE_UNITE";}
		 public function get_name_NATURE(){ return "NATURE";}
		 public function get_name_CODE_ETABLISSEMENT(){ return "CODE_ETABLISSEMENT";}
		 public function get_name_CODE_UNIVERSITE(){ return "CODE_UNIVERSITE";}
		 public function get_name_CODE_DIPLOME(){ return "CODE_DIPLOME";}
		 public function get_name_SEMESTRE(){ return "SEMESTRE";}
		 public function get_name_CODE_DOMAINE(){ return "CODE_DOMAINE";}
		 public function get_name_CODE_MENTION(){ return "CODE_MENTION";}
		 public function get_name_CODE_NIVEAU(){ return "CODE_NIVEAU";}
		 public function set_ID($parametre){  $this->_ID=$parametre;}	
		 public function set_NOM_UNITE($parametre){  $this->_NOM_UNITE=$parametre;}	
		 public function set_CODE_UNITE($parametre){  $this->_CODE_UNITE=$parametre;}	
		 public function set_NATURE($parametre){  $this->_NATURE=$parametre;}	
		 public function set_CODE_ETABLISSEMENT($parametre){  $this->_CODE_ETABLISSEMENT=$parametre;}	
		 public function set_CODE_UNIVERSITE($parametre){  $this->_CODE_UNIVERSITE=$parametre;}	
		 public function set_CODE_DIPLOME($parametre){  $this->_CODE_DIPLOME=$parametre;}	
		 public function set_SEMESTRE($parametre){  $this->_SEMESTRE=$parametre;}	
		 public function set_CODE_DOMAINE($parametre){  $this->_CODE_DOMAINE=$parametre;}	
		 public function set_CODE_MENTION($parametre){  $this->_CODE_MENTION=$parametre;}	
		 public function set_CODE_NIVEAU($parametre){  $this->_CODE_NIVEAU=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_ID(){ return $this->_ID;}
		 public function get_NOM_UNITE(){ return $this->_NOM_UNITE;}
		 public function get_CODE_UNITE(){ return $this->_CODE_UNITE;}
		 public function get_NATURE(){ return $this->_NATURE;}
		 public function get_CODE_ETABLISSEMENT(){ return $this->_CODE_ETABLISSEMENT;}
		 public function get_CODE_UNIVERSITE(){ return $this->_CODE_UNIVERSITE;}
		 public function get_CODE_DIPLOME(){ return $this->_CODE_DIPLOME;}
		 public function get_SEMESTRE(){ return $this->_SEMESTRE;}
		 public function get_CODE_DOMAINE(){ return $this->_CODE_DOMAINE;}
		 public function get_CODE_MENTION(){ return $this->_CODE_MENTION;}
		 public function get_CODE_NIVEAU(){ return $this->_CODE_NIVEAU;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 unite1(
			NOM_UNITE,
			CODE_UNITE,
			NATURE,
			CODE_ETABLISSEMENT,
			CODE_UNIVERSITE,
			CODE_DIPLOME,
			SEMESTRE,
			CODE_DOMAINE,
			CODE_MENTION,
			CODE_NIVEAU)
 VALUES(
			'".$this->_NOM_UNITE."',
			'".$this->_CODE_UNITE."',
			'".$this->_NATURE."',
			'".$this->_CODE_ETABLISSEMENT."',
			'".$this->_CODE_UNIVERSITE."',
			'".$this->_CODE_DIPLOME."',
			'".$this->_SEMESTRE."',
			'".$this->_CODE_DOMAINE."',
			'".$this->_CODE_MENTION."',
			'".$this->_CODE_NIVEAU."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_NOM_UNITE)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NOM_UNITE='".$this->_NOM_UNITE."'";
}
if(!empty($this->_CODE_UNITE)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CODE_UNITE='".$this->_CODE_UNITE."'";
}
if(!empty($this->_NATURE)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NATURE='".$this->_NATURE."'";
}
if(!empty($this->_CODE_ETABLISSEMENT)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CODE_ETABLISSEMENT='".$this->_CODE_ETABLISSEMENT."'";
}
if(!empty($this->_CODE_UNIVERSITE)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CODE_UNIVERSITE='".$this->_CODE_UNIVERSITE."'";
}
if(!empty($this->_CODE_DIPLOME)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CODE_DIPLOME='".$this->_CODE_DIPLOME."'";
}
if(!empty($this->_SEMESTRE)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
SEMESTRE='".$this->_SEMESTRE."'";
}
if(!empty($this->_CODE_DOMAINE)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CODE_DOMAINE='".$this->_CODE_DOMAINE."'";
}
if(!empty($this->_CODE_MENTION)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CODE_MENTION='".$this->_CODE_MENTION."'";
}
if(!empty($this->_CODE_NIVEAU)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CODE_NIVEAU='".$this->_CODE_NIVEAU."'";
}
$sql="UPDATE 
unite1 SET 
 ".$sql."
								WHERE ID ='".$this->_ID."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
unite1 
 
									WHERE ID ='".$this->_ID."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
unite1 ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		ID,
		NOM_UNITE,
		CODE_UNITE,
		NATURE,
		CODE_ETABLISSEMENT,
		CODE_UNIVERSITE,
		CODE_DIPLOME,
		SEMESTRE,
		CODE_DOMAINE,
		CODE_MENTION,
		CODE_NIVEAU
 FROM 
 unite1";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_ID=$row->ID;
		$this->_NOM_UNITE=$row->NOM_UNITE;
		$this->_CODE_UNITE=$row->CODE_UNITE;
		$this->_NATURE=$row->NATURE;
		$this->_CODE_ETABLISSEMENT=$row->CODE_ETABLISSEMENT;
		$this->_CODE_UNIVERSITE=$row->CODE_UNIVERSITE;
		$this->_CODE_DIPLOME=$row->CODE_DIPLOME;
		$this->_SEMESTRE=$row->SEMESTRE;
		$this->_CODE_DOMAINE=$row->CODE_DOMAINE;
		$this->_CODE_MENTION=$row->CODE_MENTION;
		$this->_CODE_NIVEAU=$row->CODE_NIVEAU;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>